//
//  MCSendHongBaoHeaderView.m
//  XDYL
//
//  Created by MC on 2018/3/20.
//  Copyright © 2018年 TLYL01. All rights reserved.
//

#import "MCSendHongBaoHeaderView.h"
#import "MCMineInfoModel.h"

@interface MCSendHongBaoHeaderView()

@property (nonatomic ,strong)UIImageView * logoImgV;
@property (nonatomic ,strong)UILabel * lab_name ;
@property (nonatomic ,strong)UILabel * lab1 ;//899.56元
@property (nonatomic ,strong)UILabel * lab2 ;//共发出999个
@property (nonatomic ,strong)UILabel * lab3 ;//共10个红包，已抢1/10（消费100&充值100）


@end

@implementation MCSendHongBaoHeaderView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    self.backgroundColor=[UIColor whiteColor];
    
    _logoImgV=[[UIImageView alloc]init];
    _logoImgV.image = [UIImage imageNamed:@"fachu"];
    [self addSubview:_logoImgV];
    [_logoImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.top.equalTo(self.mas_top).offset(14);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(100);
    }];
    
    
    CGFloat T =20;
    _lab_name=[[UILabel alloc]init];
    _lab_name.text=@"";
    _lab_name.font=[UIFont systemFontOfSize:15];
    _lab_name.textColor=RGB(255,69,69);
    _lab_name.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_lab_name];
    [_lab_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.top.equalTo(_logoImgV.mas_bottom).offset(8);
        make.width.mas_equalTo(300);
        make.height.mas_equalTo(T );
    }];
    
    
    /*
     *
     */
    _lab1=[[UILabel alloc]init];
    _lab1.text=@"加载中...";
    _lab1.font=[UIFont systemFontOfSize:18];
    _lab1.textColor=RGB(255,69,69);
    _lab1.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_lab1];
    [_lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.top.equalTo(_logoImgV.mas_bottom).offset(T);
        make.width.mas_equalTo(300);
        make.height.mas_equalTo(45);
    }];
    
    /*
     *
     */
    _lab2=[[UILabel alloc]init];
    _lab2.text=@"加载中...";
    _lab2.font=[UIFont systemFontOfSize:12];
    _lab2.textColor=RGB(161,161,161);
    _lab2.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_lab2];
    [_lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX).offset(0);
        make.top.equalTo(_logoImgV.mas_bottom).offset(30+T);
        make.width.mas_equalTo(300);
        make.height.mas_equalTo(38);
    }];
    
    
    /*
     *
     */
    _lab3=[[UILabel alloc]init];
    _lab3.text=@"加载中...";
    _lab3.font=[UIFont systemFontOfSize:12];
    _lab3.textColor=RGB(161,161,161);
    _lab3.textAlignment=NSTextAlignmentLeft;
    [self addSubview:_lab3];
    [_lab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.bottom.equalTo(self.mas_bottom).offset(-6);
        make.width.mas_equalTo(300);
        make.height.mas_equalTo(15);
    }];
    

    
    /*
     * 下划线
     */
    UIView * line =[[UIView alloc]init];
    line.backgroundColor=RGB(213,213,213);
    [self  addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-10);
        make.left.equalTo(self.mas_left).offset(10);
        make.bottom.equalTo(self.mas_bottom).offset(-1);
        make.height.mas_equalTo(0.5);
        
    }];
}


+(CGFloat)computeHeight:(id)info{
    return 199+20;
}


-(void)setDataSource:(MCSendRecordTotalModel *)dataSource{
    _dataSource = dataSource;
//    TotalAmount (number, optional): 发出的总金额 ,
//    TotalQty (integer, optional): 发出红包总个数
    
    MCMineInfoModel *mineInfoModel =[MCMineInfoModel sharedMCMineInfoModel];
    if (mineInfoModel.HeadPortrait.length<1) {
        
        _logoImgV.image=[UIImage imageNamed:@"MoRenPerson_1"];
//        _logoImgV.image = [UIImage imageNamed:@"shoubao"];
        
    }else{
        
        _logoImgV.image=[UIImage imageNamed:[NSString stringWithFormat:@"MoRenPerson_%@",mineInfoModel.HeadPortrait]];
        
    }
    NSString * userName = [[NSUserDefaults standardUserDefaults] objectForKey:@"userName"];
    if (userName.length>0) {
        _lab_name.text=[NSString stringWithFormat:@"%@",userName];
    }else{
        _lab_name.text=[NSString stringWithFormat:@"%@",mineInfoModel.UserRealName];
    }
    
    _lab1.text=[NSString stringWithFormat:@"共发出%@元",dataSource.TotalAmount];//@"520";
    _lab2.text=[NSString stringWithFormat:@"共发出%@个",dataSource.TotalQty];//@"共发出999个";
//    _lab3.text=@"共10个红包，已抢1/10（消费100&充值100）";
    _lab3.hidden=YES;
}


@end














































